package pers.linkong.asr.web;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import pers.linkong.asr.domain.VRContainerBean;
import pers.linkong.asr.service.VisualService;
import pers.linkong.asr.util.ResultInfo;
import pers.linkong.asr.util.VisualKit;

@Controller
@RequestMapping("/visual")
public class VisualController {

	@Autowired
	private VisualService visualService;
	
	@RequestMapping("/getRecordByCid")
	@ResponseBody
	public ResultInfo getRecordByCid(HttpSession session){
		int cid = (int)session.getAttribute("courseId");
		try {
			List<VRContainerBean> vrcb = VisualKit.CourseVisual(cid, visualService);
			return ResultInfo.data(1, "课程记录统计完成", vrcb);
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
			return ResultInfo.data(0, "发生异常，统计失败，请稍后再试");
		}
	}
	
	@RequestMapping("/recordTable")
	public String recordTable(int cid, HttpSession session){
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		session.setAttribute("courseId", cid);
		return "RecordTable";
	}
	
}
